<Open Tag=[<{]>
<Close Tag=[}>]>
@ModelType PagedList.IPagedList(Of <{OwnerU}>_<{TableU}>)
@Imports PagedList
@Imports PagedList.Mvc

@Code
    ViewBag.Title = "Index"
    Layout = "~/Views/Shared/_Layout.vbhtml"
End Code

<h2><{Table}></h2>

@Using (Html.BeginForm("Index", "<{Table}>", FormMethod.Get))
    @<text>
        <table class="table">
            <tr>
                <td align="left">&nbsp;</td>
                <td>&nbsp;</td>
                <td align="center">                    
                    @Html.DropDownList("SearchField", DirectCast(ViewData("SearchFields"), IEnumerable(Of SelectListItem)), New With {.style = "width:150px;height:33px"})
                    @Html.DropDownList("SearchCondition", DirectCast(ViewData("SearchConditions"), IEnumerable(Of SelectListItem)), New With {.style = "width:150px;height:33px"})
                    @Html.TextBox("SearchText", TryCast(ViewData("SearchText"), [String]), New With {.style = "width:100px;height:33px"})
                    <input type="submit" value="Search" name="command" class="btn btn-default" />
                    <input type="submit" value="Show All" name="command" class="btn btn-default" />
                </td>
                <td>&nbsp;</td>
                <td align="right">&nbsp;</td>
            </tr>
            <tr>
                <td align="left">
                    @Html.DropDownList("Export", DirectCast(ViewData("Exports"), IEnumerable(Of SelectListItem)), New With {.style = "width:65px;height:33px"})
                    <input type="submit" value="Export" name="command" class="btn btn-default" />
                </td>
                <td>&nbsp;</td>
                <td align="center">
                    <input type="submit" value="Add New Record" name="command" class="btn btn-default" />
                </td>
                <td>&nbsp;</td>
                <td align="right">
                    @Html.DropDownList("PageSize", DirectCast(ViewData("PageSizes"), IEnumerable(Of SelectListItem)), New With {.style = "width:50px;height:33px"})
                    <input type="submit" value="Page Size" name="command" class="btn btn-default" />
                </td>
            </tr>
        </table>
    </text>
End Using

<table class="table">
    <tr>
    <{If Loop}>
	        <{IsNotRelated}>
	        <{And}>
	        <{IsNotText}>
	        <{And}>
	        <{IsNotNText}>
        <th>
            @Html.ActionLink("<{FieldC}>", "Index", New With { .sortOrder = ViewData("<{FieldU}>SortParm"), .SearchText = ViewData("SearchText") })
        </th>
	        <{IsNotRelated}>
	        <{And}>
	        <{IsText}>
        <th>
            <{FieldC}>
        </th>
	        <{IsNotRelated}>
	        <{And}>
	        <{IsNText}>
        <th>
            <{FieldC}>
        </th>
	        <{IsRelated}>
	        <{And}>
	        <{IsNotText}>
	        <{And}>
	        <{IsNotNText}>
        <th>
            @Html.ActionLink("<{FieldC}>", "Index", New With { .sortOrder = ViewData("<{FieldU}>SortParm"), .SearchText = ViewData("SearchText") })
        </th>
	        <{IsRelated}>
	        <{And}>
	        <{IsText}>
        <th>
            <{FieldC}>
        </th>
	        <{IsRelated}>
	        <{And}>
	        <{IsNText}>
        <th>
            <{FieldC}>
        </th>
    <{/If Loop}>
        <th></th>
    </tr>

    @For Each item In Model
    @<tr>
    <{If Loop}>
	        <{IsNotRelated}>
        <td>
            @Html.DisplayFor(Function(modelItem) item.<{FieldU}>)
        </td>
	        <{IsRelated}>
        <td>
            @Html.DisplayFor(Function(modelItem) item.<{ROwner}>_<{RTable}>.<{RDisplayField}>)
        </td>
    <{/If Loop}>
        <td>
            @Html.ActionLink("Edit", "Edit", New With {
    <{If Loop}>
      <{IsPKey}>
      <{And}>
      <{IsCurRow=[0]}>
 						.<{FieldU}> = item.<{FieldU}> 
      <{IsPKey}>
      <{And}>
      <{IsCurRow<>[0]}>
 					       ,.<{FieldU}> = item.<{FieldU}>
    <{/If Loop}>
 						}) |
            @Html.ActionLink("Details", "Details", New With {
    <{If Loop}>
      <{IsPKey}>
      <{And}>
      <{IsCurRow=[0]}>
 						.<{FieldU}> = item.<{FieldU}> 
      <{IsPKey}>
      <{And}>
      <{IsCurRow<>[0]}>
 					       ,.<{FieldU}> = item.<{FieldU}>
    <{/If Loop}>
 						}) |
            @Html.ActionLink("Delete", "Delete", New With {
    <{If Loop}>
      <{IsPKey}>
      <{And}>
      <{IsCurRow=[0]}>
 						.<{FieldU}> = item.<{FieldU}> 
      <{IsPKey}>
      <{And}>
      <{IsCurRow<>[0]}>
 					       ,.<{FieldU}> = item.<{FieldU}>
    <{/If Loop}>
 						})
    <{If Loop}>
        	<{IsNotPKey}>
        	<{And}>
        	<{IsIdentity}>
    @Html.ActionLink("Edit", "Edit", New With { id = Model.<{FieldU}> }) |
        	<{ExitLoop}>
    <{/If Loop}>
    <{If Loop}>
        	<{IsNotIdentityCount}>
        	<{And}>
        	<{IsNotPKeyCount}>
            @Html.ActionLink("Edit", "Edit", New With { id=item.<{FieldU}> }) |
            @Html.ActionLink("Details", "Details", New With { id=item.<{FieldU}> }) |
            @Html.ActionLink("Delete", "Delete", New With { id=item.<{FieldU}> })
        	<{ExitLoop}>
    <{/If Loop}>
        </td>
    </tr>
    Next

</table>

<table class="table">
    <tr>
        <td align="center">
            @Html.PagedListPager(Model, Function(page) Url.Action("Index", New With {page, .sortOrder = ViewData("CurrentSort"), .SearchText = ViewData("SearchText")}))
        </td>
    </tr>
</table>

<Open Tag=[<]>
<Close Tag=[>]>
